package top.songxs.yygh.hosp.user.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.songxs.yygh.common.result.R;
import top.songxs.yygh.model.user.UserInfo;
import top.songxs.yygh.hosp.user.service.UserInfoService;
import top.songxs.yygh.vo.user.UserInfoQueryVo;

import java.util.Map;

@RestController
@RequestMapping("/admin/user")
public class UserController {

    //1、用户列表（条件+分页） 2、用户详情接口 3、用户的锁定和解锁

    @Autowired
    UserInfoService userInfoService;

    @GetMapping("{pageNum}/{pageSize}")
    public R getPage(@PathVariable Long pageNum,
                     @PathVariable Long pageSize ,
                     UserInfoQueryVo vo ){

            Page<UserInfo> pageParam = new Page<>(pageNum, pageSize);
        IPage<UserInfo> pageModel = userInfoService.selectPage(pageParam,vo);
        return R.ok().data("pageModel",pageModel);
    }

    @ApiOperation(value = "锁定")
    @GetMapping("lock/{userId}/{status}")
    public R lock(@PathVariable("userId")Long userId,@PathVariable("status") Integer status){

        userInfoService.lock(userId,status);
        return R.ok();
    }

    //用户详情
    @GetMapping("show/{userId}")
    public R show(@PathVariable Long userId) {
        Map<String,Object> map = userInfoService.show(userId);

        return R.ok().data(map);

    }

    //认证审批
    @GetMapping("approval/{userId}/{authStatus}")
    public R approval(@PathVariable Long userId,@PathVariable Integer authStatus) {
        userInfoService.approval(userId,authStatus);

        return R.ok();

    }
}
